﻿using System;
using System.Collections.Generic;
using System.Text;

using Vitruvian.Serialization;

namespace SpotItServerAPI
{
    [OptimisticSerialization]
    public class Category : IComparable
    {
        #region Public Properties
        public Guid Id { get; set; }
        public string Label { get; set; }
        public Category Parent { get; set; }
        #endregion

        #region Constructors
        public Category() { }
        public Category(string label)
        {
            Id = Guid.NewGuid();
            Label = label;
        }
        public Category(string label, Category parent)
        {
            Id = Guid.NewGuid();
            Label = label;
            Parent = parent;
        }
        #endregion

        #region Method for IComparable Interface
        public int CompareTo(object obj)
        {
            int result = 1;
            if (obj != null && obj.GetType() == typeof(Category))
            {
                Category otherCategory = obj as Category;
                result = this.Id.CompareTo(otherCategory.Id);
            }
            return result;
        }

        public override bool Equals(object obj)
        {
            return (CompareTo(obj)==0);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        #endregion

    }
}
